Skip to content

Fix INJECT_FACTS_AS_VARS deprecation warning#152

Merged
tersmitten merged 1 commit intoOefenweb:masterfrom
claytono:fix/ansible-facts-deprecation
Jan 27, 2026
Merged

Fix INJECT_FACTS_AS_VARS deprecation warning#152
tersmitten merged 1 commit intoOefenweb:masterfrom
claytono:fix/ansible-facts-deprecation

Conversation

@claytono
Copy link
Contributor

@claytono claytono commented Jan 25, 2026

Ansible 2.18 deprecated accessing facts like ansible_fqdn directly, preferring ansible_facts['fqdn'] instead. This will become an error in a future Ansible release.

Updated fact references:

  • ansible_fqdn -> ansible_facts['fqdn']
  • ansible_domain -> ansible_facts['domain']
  • ansible_virtualization_role -> ansible_facts['virtualization_role']
  • ansible_virtualization_type -> ansible_facts['virtualization_type']

See: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Ansible 2.18 deprecation warnings by updating all references to facts from the deprecated direct variable access format (e.g., ansible_fqdn) to the recommended dictionary format (e.g., ansible_facts['fqdn']). This change ensures compatibility with future Ansible releases where the old format will become an error.

Changes:

  • Updated virtualization fact references in task definitions to use the new dictionary format
  • Updated hostname and domain fact references in default variables to use the new dictionary format

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tasks/main.yml Updated virtualization_role and virtualization_type fact references to use ansible_facts dictionary
defaults/main.yml Updated fqdn and domain fact references in postfix_hostname, postfix_mailname, and postfix_sasl_user variables to use ansible_facts dictionary

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ansible 2.18 deprecated accessing facts like `ansible_fqdn` directly,
preferring `ansible_facts['fqdn']` instead. This will become an error
in a future Ansible release.

Updated fact references:
- ansible_fqdn -> ansible_facts['fqdn']
- ansible_domain -> ansible_facts['domain']
- ansible_virtualization_role -> ansible_facts['virtualization_role']
- ansible_virtualization_type -> ansible_facts['virtualization_type']

See: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars
@claytono claytono force-pushed the fix/ansible-facts-deprecation branch from f7de388 to 1f21b34 Compare January 25, 2026 15:31
@tersmitten tersmitten merged commit f9eda6d into Oefenweb:master Jan 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants